﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CodonSegDP;
using AlgorithmResult;
using PermutationCl;

namespace TripletSegmentationGUI
{
    public partial class BoundaryPositionTabletable : UserControl
    {
        public enum NUCLEOTID { A = 0, T = 1, C = 2, G = 3 };
        int codonSize = 3;
        int numRows = (int)Math.Pow(4, 3);
        Dictionary<String, int> codonMap = new Dictionary<string, int>();

        public Dictionary<String, int> CodonMap
        {
            get { return codonMap; }
           
        }
        private ComboBox combobox1 = new ComboBox();
        public BoundaryPositionTabletable(DataTable table)
        {
            InitializeComponent();

            this.dataGridViewTable.DataSource = table;
            combobox1.Hide();

            this.dataGridViewTable.Controls.Add(combobox1);
        }
    
       

        private void dataGridViewTable_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 8)
            {
                this.combobox1.Location = this.dataGridViewTable.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Location;
                this.combobox1.Width = this.dataGridViewTable.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Width;
                //     combobox1.Dock = DockStyle.Fill;
                this.combobox1.Items.Clear();
                char[] sepator = new char[4];
                sepator[0] = '\n';
                sepator[1] = ',';
                sepator[2] = ' ';
                sepator[3] = '\r';
                String BoundaryString = this.dataGridViewTable.SelectedCells[0].Value.ToString();
                String[] boundaries = BoundaryString.Split(sepator);
                foreach (String boundary in boundaries)
                {
                    if (boundary != "")
                        this.combobox1.Items.Add(boundary);
                }
                this.combobox1.SelectedIndex = 0;


                this.combobox1.Show();
                this.combobox1.DroppedDown = true;
            }
          
        }

        private void dataGridViewTable_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            this.combobox1.Hide();
        }
    }
}
